import { Component, PropsWithChildren } from 'react'
import { View, Text, Image, Button } from '@tarojs/components'
import { AtIcon } from "taro-ui"
import { getGroupBuy } from '../../api/home'
import './index.scss'
import Taro from '@tarojs/taro'

export default class Index extends Component<PropsWithChildren> {
  state: any
  constructor(props) {
    super(props)
    this.state = {
      GroupbuyList: []
    }
  }
  componentWillMount() { }

  componentDidMount() {
    this.getGroupbuy()
  }

  componentWillUnmount() { }

  componentDidShow() { }

  componentDidHide() { }
  getGroupbuy() {
    getGroupBuy().then((res) => {
      this.setState({
        GroupbuyList: res.data.data
      })
    })
  }
  onClick() {
    Taro.switchTab({
      url: '/pages/index/index'
    })
  }
  render() {
    return (
      <View className='index'>
        <View className='nav-bar-box'>
          <View className='status-bar'></View>
          <View className='title-bar'>
            <AtIcon onClick={this.onClick.bind(this)} className='icon' value='chevron-left' size='24' color='#fff'></AtIcon>
            <Text className='tit'>团购看房</Text>
          </View>
        </View>
        <View className='container'>
          {
            this.state.GroupbuyList?.map((item: any, index: number) => {
              return <View className='Nums' key={index}>
                <Button key={index} className={index===0?'btn1':'btn'}>{item.btn}</Button>
                <Button key={index} className={index===1?'btn2':'btn'}>{item.btn1}</Button>
                <Button key={index} className={index===2?'btn3':'btn'}>{item.btn2}</Button>
                <Image className='img' src={item.imgUrl} />
                <View className='des'>
                  <View className='tit'>{item.title}</View>
                  <View>{item.desc}</View>
                  <View>集合地点: {index===2?`${item.address}`:'暂无'}</View>
                  <View>车辆牌号: {index===2?`${item.car}`:'暂无'}</View>
                  <View>{item.time}</View>
                  <View>联系电话: {index===2?`${item.phone}`:'暂无'}
                    <Text>已报名: {item.people}</Text>
                  </View>
                </View>
              </View>
            })
          }
          {/* <View className='Nums'>
            <Button className='btn1'>我要报名</Button>
            <Image className='img' src='https://img1.baidu.com/it/u=1342130754,306943470&fm=253&fmt=auto&app=138&f=JPEG?w=889&h=500' />
            <View className='des'>
              <View className='tit'>恒大湖山半岛</View>
              <View>北京市石景山区456号</View>
              <View>活动时间: 202.4.17-2021.5.17
                <Text>已报名: 21人</Text>
              </View>
            </View>
          </View>
          <View className='Nums'>
            <Button className='btn2'>已报名</Button>
            <Image className='img' src='https://img1.baidu.com/it/u=1993417918,2447354163&fm=253&fmt=auto&app=120&f=JPEG?w=641&h=394' />
            <View className='des'>
              <View className='tit'>恒大湖山半岛</View>
              <View>北京市石景山区456号</View>
              <View>活动时间: 202.4.17-2021.5.17
                <Text>已报名: 21人</Text>
              </View>
            </View>
          </View>
          <View className='Nums'>
            <Button className='btn3'>已开团</Button>
            <Image className='img' src='https://img0.baidu.com/it/u=1649151030,2162866999&fm=253&fmt=auto&app=138&f=JPEG?w=889&h=500' />
            <View className='des'>
              <View className='tit'>恒大湖山半岛</View>
              <View>北京市石景山区456号</View>
              <View>集合地点: 北京市石景山地铁站A口</View>
              <View>车辆牌号: 京A34553</View>
              <View>集合时间: 202.4.17   9:00</View>
              <View>联系电话: 15248373934
                <Text>已报名: 21人</Text>
              </View>
            </View>
          </View> */}
          <Button className='btn3'></Button>
        </View>
      </View >
    )
  }
}

// https://img1.baidu.com/it/u=1342130754,306943470&fm=253&fmt=auto&app=138&f=JPEG?w=889&h=500
// https://img0.baidu.com/it/u=3295534422,3155222370&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=334
// https://img1.baidu.com/it/u=2064254833,770634332&fm=253&fmt=auto&app=138&f=JPEG?w=800&h=500
// https://img1.baidu.com/it/u=1144874046,3925078084&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=375
// https://img2.baidu.com/it/u=3849720705,1881524056&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=334
// https://img0.baidu.com/it/u=1649151030,2162866999&fm=253&fmt=auto&app=138&f=JPEG?w=889&h=500
// https://img1.baidu.com/it/u=1993417918,2447354163&fm=253&fmt=auto&app=120&f=JPEG?w=641&h=394